<%@ page language="java" pageEncoding="UTF-8" %>
<%@ page language="java" import="java.util.*" %>
<%@ page import="com.alibaba.fastjson.*" %>
<%@ page import="com.gin.util.Info" %>
<%@ page import="com.gin.util.Query" %>

<%


    if (request.getParameter("f") != null) {


        String json1 = request.getParameter("JSON");
        String id = request.getParameter("id");
        JSONArray json = JSON.parseArray(json1);
        JSONObject leixingdefen = JSON.parseObject(request.getParameter("leixingdefen"));
        JSONObject map = JSON.parseObject(request.getParameter("map"));
        HashMap data = new HashMap();

        String kaoshibianhao = Info.getID();
        data.put("kaoshibianhao", kaoshibianhao);
        data.put("kaoshiren", request.getSession().getAttribute("username"));
        //data.put("quanxian", request.getSession().getAttribute("cx"));
        data.put("addtime", Info.getDateStr());

        HashMap m = new HashMap();
        for (int i = 0; i < json.size(); i++) {
            JSONObject obj = json.getJSONObject(i);
            obj.putAll(data);
            obj.put("shitiid", obj.get("id"));
            obj.remove("id");

            m.putAll(obj);
            // m.put("fenlei" , map.get("fenlei"));
            int defen = obj.getIntValue("defen");

            Integer.valueOf(String.valueOf(obj.get("defen"))).intValue();

            Query.make("kaoshijieguo").insert(m);


        }

        HashMap jieguo = new HashMap();
        jieguo.putAll(m);

        Integer total = Integer.valueOf(request.getParameter("zongdefen"));

        jieguo.put("kaoshibianhao", kaoshibianhao);
        jieguo.put("danxuantidefen", leixingdefen.get("单选题") == null ? 0 : leixingdefen.get("单选题"));
         jieguo.put("duoxuantidefen", leixingdefen.get("多选题") == null ? 0 : leixingdefen.get("多选题"));
         jieguo.put("panduantidefen", leixingdefen.get("判断题") == null ? 0 : leixingdefen.get("判断题"));
        jieguo.put("zongdefen", total);





        long insertId = Query.make("kaoshidefen").insert(jieguo);
        System.err.println(insertId);

        out.clear();
        out.clearBuffer();
        out.println("{code:0,data:" + insertId + "}");
        out.close();
    } else {
        out.println("{code:1,msg:\"信息提交失败\"}");
        out.close();
    }
%>